package cn.jtfadmin.codegen.domain.entity;

import cn.jtfadmin.base.data.jpa.domain.entity.BaseEntity;
import cn.jtfadmin.base.filesystem.annos.File;
import cn.jtfadmin.base.lang.enums.FileType;
import cn.jtfadmin.codegen.enums.FieldTypeEnum;
import cn.jtfadmin.codegen.enums.InputTypeEnum;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 代码生成字段信息
 */
@Entity
@Table(name = "code_gen_field")
@Getter
@Setter
public class CodeGenFieldEntity extends BaseEntity implements Serializable {


    /**
     * 字段类型
     */
    @Column(name = "field_type")
    protected FieldTypeEnum fieldType;

    /**
     * 字段名称
     */
    @Column(name = "name")
    protected String name;
    /**
     * 字段类型名
     */
    @Column(name = "field_class_name")
    protected String fieldClassName;

    /**
     * 字段输入类型
     */
    @Column(name = "input_type")
    protected InputTypeEnum inputType;

    /**
     * 字段是否是lob,字段类型为String时有效
     */
    @Column(name = "lob")
    protected Boolean lob;



    /**
     * 注释
     */
    @Column(name = "comment")
    protected String comment;



    /**
     * 字段排序
     */
    @Column(name = "sort")
    protected Integer sort;

    // 字段是集合时
    /**
     * 关联关系是否是一对多
     */
    @Column(name = "one_to_many")
    protected Boolean oneToMany;

    /**
     * 关联关系是否是多对多
     */
    @Column(name = "many_to_many")
    protected Boolean manyToMany;

    /**
     * 集合类型
     */
    @Column(name = "collection_class_name")
    protected String collectionClassName;

    /**
     * 多对多关联表
     */
    @Column(name = "join_table_name")
    protected String joinTableName;

    /**
     * 多对多关联表关联字段
     */
    @Column(name = "join_table_jc_name")
    protected String joinTableJcName;
    /**
     * 多对多关联表对方关联字段
     */
    @Column(name = "join_table_ijc_name")
    protected String joinTableIjcName;

    // 字段是其他实体类
    /**
     * 关联关系是否是多对一
     */
    @Column(name = "many_to_one")
    protected Boolean manyToOne;

    /**
     * 关联关系是否是一对一
     */
    @Column(name = "one_to_one")
    protected Boolean oneToOne;

    /**
     * 级联关系
     */
    @Column(name = "cas_cade")
    protected String cascade;

    /**
     * 加载关系
     */
    @Column(name = "fetch_type")
    protected String fetch;


    /**
     * 一对一，一对多时有用,关系维护方字段
     */
    @Column(name = "mapped_by")
    protected String mappedBy;


    /**
     * 关联字段，一对一，多对一是有用
     */
    @Column(name = "join_column_name")
    protected String joinColumnName;

    /**
     * 展示列名
     */
    @Column(name = "show_column_name")
    protected String showColumnName;






    /**
     * 必须
     */
    @Column(name = "required")
    protected Boolean required;

    /**
     * 最大,字符串长度/数字
     */
    @Column(name = "max")
    protected BigDecimal max;

    /**
     * 最小，字符串长度/数字
     */
    @Column(name = "min")
    protected BigDecimal min;

    /**
     * 如果为文件时文件类型
     */
    @Column(name = "file_type")
    protected FileType fileType;


    /**
     * 文件目录
     */
    @Column(name = "file_dir")
    protected String fileDir;

    /**
     * 如果为文件时，文件最大上传数量
     */
    @Column(name = "file_num")
    protected Integer fileNum;

    @Column(name = "file_describe")
    protected String fileDescribe;

    /**
     * 是否修改文件名
     */
    @Column(name = "file_update_name")
    protected Boolean fileUpdateName;

    /**
     * 是否唯一
     */
    @Column(name = "unique_flag")
    protected Boolean unique;


    /**
     * 列表
     */
    @Column(name = "list_item")
    protected Boolean listItem;

    /**
     * 新增项
     */
    @Column(name = "add_item")
    protected Boolean addItem;

    /**
     * 编辑项
     */
    @Column(name = "edit_item")
    protected Boolean editItem;

    /**
     * model项
     */
    @Column(name = "model_item")
    protected Boolean modelItem;

    /**
     * excel 项
     */
    @Column(name = "excel_item")
    protected Boolean excelItem;

    @Column(name = "select_item")
    protected Boolean selectItem;

    /**
     * 列表内嵌
     */
    @Column(name = "list_embed", length = 2000)
    protected String listEmbed;

    /**
     * 内嵌查询
     */
    @Column(name = "select_embed", length = 2000)
    protected String selectEmbed;

    /**
     * 内嵌excel字段
     */
    @Column(name = "excel_embed", length = 2000)
    protected String excelEmbed;


    @Column(name = "model_embed", length = 2000)
    protected String modelEmbed;


    /**
     * 内嵌excel字段Id
     */
    @Column(name = "excel_embed_id", length = 2000)
    protected String excelEmbedId;

    /**
     * 是否是excel Id
     */
    @Column(name = "excel_id")
    protected Boolean excelId;



}
